package dao;

import bean.Room;
import bean.User;
import org.apache.commons.dbutils.QueryRunner;
import util.C3p0Util;

import java.sql.SQLException;
import java.util.Scanner;

public class DeleteRoomDao {
    public int deleteRoom(Room room){
        int count = 0;
        QueryRunner runner = new QueryRunner(C3p0Util.getDs());
        String sql = "delete from t_room where r_number = ?";

        try {
            /*
                - update DML 针对增、删、改的语句都可以使用
                    参数1：sql
                    参数2：可变数组，存放的是占位符对应的数据值
             */
            count = runner.update(sql,room.getrNumber());
            if(count > 0){
                System.out.println("执行成功");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return count;
    }

    public static void main(String[] args) {
        Room room = new Room();
        Scanner sc = new Scanner(System.in);
        DeleteRoomDao drd = new DeleteRoomDao();
        System.out.println("请输入需要删除的房间号：");
        int a = sc.nextInt();
        room.setrNumber(a);
        drd.deleteRoom(room);


    }
}
